package com.itheima.service.Impl;



import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.common.SubjectResult;
import com.itheima.mapper.HmSubjectsTagsMapper;
import com.itheima.pojo.hm.HmSubjectsTags;
import com.itheima.service.HmSubjectsTagsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class HmSubjectsTagsServiceImpl implements HmSubjectsTagsService {
    @Autowired
    private HmSubjectsTagsMapper hmSubjectsTagsMapper;

    @Override
    public List<SubjectResult> SimpleTag(Integer subjectID) {
        LambdaQueryWrapper<HmSubjectsTags> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HmSubjectsTags::getSubjectID, subjectID);
        List<HmSubjectsTags> hmSubjectsTags = hmSubjectsTagsMapper.selectList(wrapper);
        List<SubjectResult> resultList = new ArrayList<>();
        for (HmSubjectsTags hmSubjectsTag : hmSubjectsTags) {
            SubjectResult subjectResult = new SubjectResult();
            subjectResult.setValue(hmSubjectsTag.getId());
            subjectResult.setLabel(hmSubjectsTag.getTagName());
            resultList.add(subjectResult);
        }
        return resultList;
    }
}
